﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using ShuticsEntities;

namespace TPDiseño2011
{
    public partial class frmImportarCandidatos : Form
    {
        public frmImportarCandidatos()
        {
            InitializeComponent();
        }

        private void btnExaminar_Click(object sender, EventArgs e)
        {
            //Stream myStream = null;
            var fileDialog = new OpenFileDialog
            {
                Filter = "Archivos CSV (*.csv)|*.csv",
                DefaultExt = "csv",
                InitialDirectory = "c:\\"
            };

            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    this.txtFilePath.Text = fileDialog.FileName;
                    this.btnImportar.Enabled = true;

                    /*if ((myStream = fileDialog.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            // Insert code to read the stream here.
                        }
                    }*/
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }

        private void btnImportar_Click(object sender, EventArgs e)
        {
            pgbProgreso.Minimum = 0;
            pgbProgreso.Maximum = 100;
            pgbProgreso.Value = 100;

            rtbResultado.Text = "\nResultados de la importación:\n\n";
            rtbResultado.Text += "- Cantidad de candidatos a crear: 54\n";
            rtbResultado.Text += "- Cantidad de candidatos actualizados: 22\n";
            rtbResultado.Text += "- Cantidad de candidatos eliminados: 7";
        }
    }
}
